/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.gob.mh.dgii.model.validators;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import sv.gob.mh.dgii.common.Utils;
import sv.gob.mh.dgii.model.TbMunicipio;
import sv.gob.mh.dgii.model.custom.constraints.TbMunicipioNotEmpty;

/**
 *
 * @author hgonzalez
 */
public class TbMunicipioValidator implements ConstraintValidator<TbMunicipioNotEmpty, TbMunicipio> {

    
    public void initialize(TbMunicipioNotEmpty a) {        
    }
    
    public boolean isValid(TbMunicipio muni, ConstraintValidatorContext cvc) {        
        if(Utils.isNullOrEmpty(muni))return false;
        if(Utils.isNullOrEmpty(muni.getId()))return false;
        if(Utils.isNullOrEmpty(muni.getTbDepartamento()))return false;
        //if(Utils.isNullOrEmpty(muni.getId().getCmunicipio()))return false;
        return true;
    }
    
}
